#!/usr/bin/env bash

echo "systemctl enable kubelet" > add-work-node.sh
echo "systemctl enable kubelet" > add-master-node.sh

grep -A 5 "control-plane node"  kubeadm-init.log  | grep -A 2 "kubeadm join" | tail -n 3  >> add-master-node.sh
sed -i 's@kubeadm join@kubeadm join --cri-socket unix:///run/containerd/containerd.sock @'  add-master-node.sh

grep -A 5 "worker nodes"  kubeadm-init.log  | grep -A 1 "kubeadm join" | tail -n 2  >> add-work-node.sh
sed -i 's@kubeadm join@kubeadm join --cri-socket unix:///run/containerd/containerd.sock @'  add-work-node.sh

chmod a+x add-work-node.sh add-master-node.sh

echo "cat add-master-node.sh:" 
cat add-master-node.sh

echo "------"
echo "cat add-work-node.sh:" 
cat add-work-node.sh

